﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace Tin
{
    class Report
    {
        public static DataTable GetTable(List<TPoint> points)
        {
            DataTable table = new DataTable();
            GetTableHeader(ref table);
            GetData(ref table, points);
            return table;
        }

        private static void GetTableHeader(ref DataTable table)
        {
            table.Columns.Add("点名", typeof(string));
            table.Columns.Add("X分量", typeof(string));
            table.Columns.Add("Y分量", typeof(string));
            table.Columns.Add("Z分量", typeof(string));
        }

        private static void GetData(ref DataTable table, List<TPoint> points)
        {
            for (int i=0;i<points.Count;i++)
            {
                DataRow row = table.NewRow();
                row["点名"] = points[i].Name;
                row["X分量"] = points[i].X;
                row["Y分量"] = points[i].Y;
                row["Z分量"] = points[i].Z;
                table.Rows.Add(row);
            }
        }
    }
}
